/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.bitacora.Dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.dsw2.bitacora.modelo.Carros;

/**
 *
 * @author Etts
 */
@Stateless
public class CarrosDao extends AbstractDao<Carros> implements CarrosDaoLocal {
    @PersistenceContext(unitName = "Bitacora-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CarrosDao() {
        super(Carros.class);
    }
    
    
    @Override
public boolean findDuplicity(Carros carros) {
//seleccionar consulta
Query q= em.createNamedQuery("Carros.findDuplicity");
//poner parametros
q.setParameter("matricula",carros.getMatricula());

//ejecutar
return !q.getResultList().isEmpty();
}
}
